package com.cetc.sdp.kmga.cs.util;

import com.google.common.util.concurrent.ThreadFactoryBuilder;

import java.util.concurrent.*;

/**
 * @description:
 * @author： DengQiang
 * @date: 2017/10/13 10:10
 */
public final class ThreadPool {

    private ThreadPool () {}

    private volatile static ExecutorService executorService;

    public static ExecutorService getExecutorService() {
        if (executorService == null) {
            synchronized (ThreadPool.class) {
                if (executorService == null) {
                    executorService = new ThreadPoolExecutor(24, 24
                            , 100, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>()
                            , new ThreadFactoryBuilder().setNameFormat("Custom-Node-Thread-%d").build());
                }
            }
        }
        return executorService;
    }
}
